/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CancelaIngressoEmPe.java
 *
 * Created on 28/06/2012, 03:11:22
 */
package View;

import Controller.Controller;
import Model.Cargo;
import Model.Evento;
import javax.swing.JOptionPane;

/**
 *
 * @author Rodrigo
 */
public class CancelaIngressoEmPe extends javax.swing.JFrame {

    private Controller controller;
    private Evento evento;

    /**
     * Creates new form CancelaIngressoEmPe
     */
    public CancelaIngressoEmPe(Evento evento) {
        this.evento = evento;
        controller = Controller.getInstance();
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        pistaNormal = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        confirmarNormal = new javax.swing.JButton();
        pistaVip = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        confirmarVIP = new javax.swing.JButton();
        camarote = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        confirmarCamarote = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setText("Cancelar Ingresso");

        pistaNormal.setBackground(new java.awt.Color(120, 255, 171));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
        jLabel5.setText("Pista Normal");

        confirmarNormal.setText("Confirmar");
        confirmarNormal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmarNormalActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pistaNormalLayout = new javax.swing.GroupLayout(pistaNormal);
        pistaNormal.setLayout(pistaNormalLayout);
        pistaNormalLayout.setHorizontalGroup(
            pistaNormalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pistaNormalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(325, 325, 325)
                .addComponent(confirmarNormal)
                .addGap(39, 39, 39))
        );
        pistaNormalLayout.setVerticalGroup(
            pistaNormalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pistaNormalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                .addComponent(confirmarNormal)
                .addContainerGap())
        );

        pistaVip.setBackground(new java.awt.Color(255, 255, 120));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
        jLabel4.setText("Pista VIP");

        confirmarVIP.setText("Confirmar");
        confirmarVIP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmarVIPActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pistaVipLayout = new javax.swing.GroupLayout(pistaVip);
        pistaVip.setLayout(pistaVipLayout);
        pistaVipLayout.setHorizontalGroup(
            pistaVipLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pistaVipLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pistaVipLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pistaVipLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pistaVipLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(confirmarVIP)
                        .addGap(36, 36, 36))))
        );
        pistaVipLayout.setVerticalGroup(
            pistaVipLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pistaVipLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabel4)
                .addGap(36, 36, 36)
                .addComponent(confirmarVIP)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        camarote.setBackground(new java.awt.Color(255, 120, 120));

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
        jLabel3.setText("Camarote");

        confirmarCamarote.setText("Confirmar");
        confirmarCamarote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmarCamaroteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout camaroteLayout = new javax.swing.GroupLayout(camarote);
        camarote.setLayout(camaroteLayout);
        camaroteLayout.setHorizontalGroup(
            camaroteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(camaroteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(camaroteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(camaroteLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addContainerGap(460, Short.MAX_VALUE))
                    .addGroup(camaroteLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(confirmarCamarote)
                        .addGap(39, 39, 39))))
        );
        camaroteLayout.setVerticalGroup(
            camaroteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(camaroteLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(confirmarCamarote)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        jButton1.setText("Voltar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(43, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(pistaNormal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pistaVip, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(camarote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(193, 193, 193)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(58, 58, 58)
                        .addComponent(jButton1)))
                .addContainerGap(206, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel1)
                .addGap(28, 28, 28)
                .addComponent(pistaVip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pistaNormal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(camarote, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void confirmarNormalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmarNormalActionPerformed

        // TODO add your handling code here:         if (!controller.vendeIngressoEmPe('n', evento)) {             JOptionPane.showMessageDialog(null, "Setor lotado! Por favor, escolha outro.", "Erro", JOptionPane.ERROR_MESSAGE);         } else {             JOptionPane.showMessageDialog(null, "Compra efetuada com sucesso!", "Sucesso", JOptionPane.INFORMATION_MESSAGE);         }     }//GEN-LAST:event_confirmarNormalActionPerformed
        if (!controller.cancelaIngressoEmPe('n', evento)) {
            JOptionPane.showMessageDialog(null, "Não foi possível.", "Erro", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "Ingresso Cancelado!", "Sucesso", JOptionPane.INFORMATION_MESSAGE);
        }
    }
        private void confirmarVIPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmarVIPActionPerformed
        // TODO add your handling code here:         if (!controller.vendeIngressoEmPe('v', evento)) {             JOptionPane.showMessageDialog(null, "Setor lotado! Por favor, escolha outro.", "Erro", JOptionPane.ERROR_MESSAGE);         } else {             JOptionPane.showMessageDialog(null, "Compra efetuada com sucesso!", "Sucesso", JOptionPane.INFORMATION_MESSAGE);         }     }//GEN-LAST:event_confirmarVIPActionPerformed
        if (!controller.cancelaIngressoEmPe('v', evento)) {
            JOptionPane.showMessageDialog(null, "Não foi possível.", "Erro", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "Ingresso Cancelado", "Sucesso", JOptionPane.INFORMATION_MESSAGE);
        }
    }
        private void confirmarCamaroteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmarCamaroteActionPerformed
        // TODO add your handling code here:         if (!controller.vendeIngressoEmPe('c', evento)) {             JOptionPane.showMessageDialog(null, "Setor lotado! Por favor, escolha outro.", "Erro", JOptionPane.ERROR_MESSAGE);         } else {             JOptionPane.showMessageDialog(null, "Compra efetuada com sucesso!", "Sucesso", JOptionPane.INFORMATION_MESSAGE);         }     }//GEN-LAST:event_confirmarCamaroteActionPerformed
        if (!controller.cancelaIngressoEmPe(
                'c', evento)) {
            JOptionPane.showMessageDialog(null, "Setor lotado! Por favor, escolha outro.", "Erro", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(null, "Ingresso Cancelado!", "Sucesso", JOptionPane.INFORMATION_MESSAGE);
        }

    }
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
            if (controller.getCargo() == Cargo.GERENTE) {
                VerEventoGerente veg = new VerEventoGerente(evento);
                veg.setVisible(true);
                this.setVisible(false);
            } else {
                VerEventoBilheteria veb = new VerEventoBilheteria(evento);
                veb.setVisible(true);
                this.setVisible(false);
            }
    }//GEN-LAST:event_jButton1ActionPerformed

    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CancelaIngressoEmPe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CancelaIngressoEmPe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CancelaIngressoEmPe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CancelaIngressoEmPe.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new CancelaIngressoEmPe(new Evento()).setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel camarote;
    private javax.swing.JButton confirmarCamarote;
    private javax.swing.JButton confirmarNormal;
    private javax.swing.JButton confirmarVIP;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel pistaNormal;
    private javax.swing.JPanel pistaVip;
    // End of variables declaration//GEN-END:variables
}
